package com.lory.controller;

import com.lory.pojo.User;
import com.lory.service.UserService;
import com.lory.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 查询列表
     * @return
     */
    @RequestMapping("/list")
    public Result list(){
        List<User> users = null;
        try {
            users = userService.list();
            return Result.ok(users);
        }catch (Exception e){
            e.printStackTrace();
            return Result.error("查询数据异常");
        }
    }


}
